{include file="common/meta" title='列表' /}
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card" style="padding-bottom: 100px;">
            <div style="width: 96%;margin: 0 auto;">
              <div class="layui-form" style="padding-top: 30px;">
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">时间范围</label>
                        <div class="layui-input-inline">
                          <input type="text" class="layui-input" id="test10" placeholder="年-月-日 - 年-月-日" autocomplete="off">
                        </div>
                        <div class="layui-input-inline">
                          <input type="text" name="kay" id="kay" autocomplete="off" placeholder="请输入操作者" class="layui-input">
                        </div>
                    <button class="layui-btn layui-btn-sm" id="sub">提交</button>
                  </div>
                </div>
              </div>
              <table class="layui-hide" id="demo" lay-filter="test"></table>
              </div>
          </div>
        </div>
      </div>
  </div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="dels">批量删除</button>
  </div>
</script>
<script type="text/html" id="barDemo">
</script>
<script src="__STATIC__/layui/layui.js"></script>
  <script type="text/html" id="switchTpl">
  	 <input type="checkbox" name="sta" value="{{d.id}}" lay-skin="switch" lay-filter="sta" lay-text="是|否"  {{ d.sta == 1 ? 'checked' : '' }}>
  </script>
<script>
layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element'], function(){
  var laydate = layui.laydate //日期
  ,laypage = layui.laypage //分页
  ,layer = layui.layer //弹层
  ,table = layui.table //表格
  ,carousel = layui.carousel //轮播
  ,upload = layui.upload //上传
  ,element = layui.element //元素操作
  ,$ = layui.$
	,form = layui.form;
 //日期时间范围
  laydate.render({
    elem: '#test10'
    ,type: 'datetime'
	,range: ','
	,format: 'yyyy-M-d'
  });
  //执行一个 table 实例
  table.render({
    elem: '#demo'
    ,url: '{:url("adminlog/datas")}' //数据接口
    ,page: true //开启分页
	, id: 'testReload'
  ,toolbar: '#toolbarDemo'
  // ,totalRow:true
    ,cols: [[ //表头
      {type: 'checkbox', fixed: 'left'}
      // ,{field: 'id', title: 'ID', sort: true, fixed: 'left', totalRowText: '合计：'}
      ,{field: 'adminname', title: '操作者', width:120}
      ,{field: 'title', title: '列表', width:120}
      ,{field: 'save', title: '操作', width:120}

      ,{field: 'createtime', title: '操作时间', width:200}
      ,{field: 'ip', title: 'ip', width:200}
      ,{field: 'com', title: '操作内容'}
    ]]
  });

  //工具栏事件
  table.on('toolbar(test)', function(obj){
  var checkStatus = table.checkStatus(obj.config.id);
  switch(obj.event){
    case 'dels':
      var data = checkStatus.data;
      if(data.length==0){
        notify.error("请先选择要删除数据", 'topRight');
        return;
      }
      var ids=new Array();
      for(var i=0;i<data.length;i++){
        if(data[i]){
          ids.push(data[i].id);
        }
      }
      ids=ids.join(',');
      layer.confirm('确定要批量删除吗？', function(index){
        // layer.msg(data.id, {time: 2000});
        $.post("{:url('adminlog/dels_list')}",{ids:ids},function(res){
          layer.closeAll();
          if(res.code=='200'){
            table.reload('testReload');
            notify.success('操作成功', 'topRight');
            //layer.close(index);
            }else{
              notify.error(res.msg, 'topRight');
            //layer.msg(res.msg, {time: 2000});
          }
        },'json');
      })
    break;



  };
});
	//搜索
  $('#sub').click(function () {
    var kay=$('#kay').val();
	var time=$('#test10').val();
    table.reload('testReload', {
    url: '{:url("adminlog/datas")}'
    // ,methods:"post"
    ,where: {
      kay : kay,
      time:time,
    }
    ,page: {
     curr: 1
    }
    });
   })
});
</script>
</body>
</html>        
